package com.neusoft.neuiotms.dcom.model.report;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.validator.constraints.Length;

import com.neusoft.bizcore.web.jpa.model.AbstractAuditModel;
import com.neusoft.bizcore.web.jpa.model.Comment;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@ToString
@Entity
@org.hibernate.annotations.Table(appliesTo = "neuiot_report_tool", comment = "报表工具表")
@Table(name = "neuiot_report_tool")
public class ReportTool extends AbstractAuditModel {

    private static final long serialVersionUID = -6686317408847541800L;

    /** 名称 */
    @NotBlank(message = "名称不能为空")
    @Length(max = 255, message = "名称不能超过{max}位")
    @Column(length = 255, nullable = false)
    @Comment("varchar(255) NOT NULL COMMENT '名称'")
    private String name;

    /** 编码 */
    @NotBlank(message = "编码不能为空")
    @Length(max = 255, message = "编码不能超过{max}位")
    @Column(length = 255, nullable = false)
    @Comment("varchar(255) NOT NULL COMMENT '编码'")
    private String code;

    /** 查询sql */
    @Lob
    @Column(columnDefinition = "text")
    @Comment("text COMMENT '查询sql'")
    private String selectSql;

    @OneToMany(mappedBy = "reportTool", cascade = {CascadeType.ALL })
    @LazyCollection(LazyCollectionOption.FALSE)
    List<ReportToolItem> reportToolItem = new ArrayList<>();

}
